﻿Imports PBE.Market.Logic.Contracts
Namespace Logic.Contracts
    Public MustInherit Class cContractBase
        Implements iContract

#Region "Feilds"
        Friend _Balance As Double?
        Friend _ContractID As String
        Friend _ContractType As String
        Friend _Currency As String
        Friend _InterestRate As Double?
        Friend _MaturityDate As Date?
        Friend _ReportDate As Date?
        Friend _PaymentSchedual As New List(Of PaymentSchedual)
        Friend _CalculateCurrentSetelmentDate As Date
        Friend _CalculateRemainingSeltelemntsNumber As Integer
        Friend _cycleofPayment As String
        Friend _ContractMajorGroup As String
        Friend _ContractProductCode As String
        Friend _ContractProductDiscription As String
        Friend _ContractTag As String
        Friend _ResponsableGL As String
#End Region

#Region "Properties"



        Public Property Balance As Double? Implements iContract.Balance
            Get
                Return _Balance
            End Get
            Set(ByVal value As Double?)
                If IsDBNull(value) Then
                    _Balance = 0
                Else
                    _Balance = value
                End If
            End Set
        End Property

        Public Property CycleOfPayment() As String Implements iContract.CycleOfPayment
            Get
                Return _cycleofPayment
            End Get
            Set(ByVal value As String)
                If IsDBNull(value) Or value = String.Empty Then
                    _cycleofPayment = "1M"
                Else
                    _cycleofPayment = value
                End If
            End Set
        End Property

        Public Property ContractMajorGroup() As String Implements iContract.ContractMajorGroup
            Get
                Return _ContractMajorGroup
            End Get
            Set(ByVal value As String)
                _ContractMajorGroup = value
            End Set
        End Property

        Public Property ContractProductCode() As String Implements iContract.ContractProductCode
            Get
                Return _ContractProductCode
            End Get
            Set(ByVal value As String)
                _ContractProductCode = value
            End Set
        End Property

        Public Property ContractProductDiscription() As String Implements iContract.ContractProductDiscription
            Get
                Return _ContractProductDiscription
            End Get
            Set(ByVal value As String)
                _ContractProductDiscription = value
            End Set
        End Property

        Public Property ContractTag() As String Implements iContract.ContractTag
            Get
                Return _ContractTag
            End Get
            Set(ByVal value As String)
                If IsDBNull(value) Or value = String.Empty Then
                    _ContractTag = ""
                Else
                    _ContractTag = value
                End If
            End Set
        End Property

        Public Property ResponsableGL() As String Implements iContract.ResponsableGL
            Get
                Return _ResponsableGL
            End Get
            Set(ByVal value As String)
                If IsDBNull(value) Or value = String.Empty Then
                    _ResponsableGL = ""
                Else
                    _ResponsableGL = value
                End If
            End Set
        End Property

        Public ReadOnly Property PaymentSchedaul() As List(Of PaymentSchedual) Implements iContract.PaymentSchedaul
            Get
                Return _PaymentSchedual
            End Get
        End Property

        Public Property ContractID As String Implements iContract.ContractID
            Get
                Return _ContractID
            End Get
            Set(ByVal value As String)
                _ContractID = value
            End Set
        End Property

        Public Property ContractType As String Implements iContract.ContractType
            Get
                Return _ContractType
            End Get
            Set(ByVal value As String)
                _ContractType = value
            End Set
        End Property

        Public Property Currency As String Implements iContract.Currency
            Get
                Return _Currency
            End Get
            Set(ByVal value As String)
                _Currency = value
            End Set
        End Property

        Public Property InterestRate As Double? Implements iContract.InterestRate
            Get
                Return _InterestRate
            End Get
            Set(ByVal value As Double?)
                If IsDBNull(value) Then
                    _InterestRate = 0
                Else
                    _InterestRate = value
                End If
            End Set
        End Property

        Public Property MaturityDate As Date? Implements iContract.MaturityDate
            Get
                Return _MaturityDate
            End Get
            Set(ByVal value As Date?)
                If IsDBNull(value) Then
                    _MaturityDate = Now.Date
                Else
                    _MaturityDate = value
                End If

            End Set
        End Property

        Public Property ReportDate As Date? Implements iContract.ReportDate
            Get
                Return _ReportDate
            End Get
            Set(ByVal value As Date?)
                If IsDBNull(value) Then
                    _ReportDate = Now.Date
                Else
                    _ReportDate = value
                End If
            End Set

        End Property
#End Region

#Region "Constractor"
        Sub New()

        End Sub
#End Region

#Region "Methods"
        Public MustOverride Function CalculatePaymnetSchedaul() As System.Collections.Generic.List(Of MdulLogic.PaymentSchedual) Implements iContract.CalculatePaymnetSchedaul


        Public MustOverride Function CalculateRemainingSeltelemntsNumber() As Integer Implements iContract.CalculateRemainingSeltelemntsNumber


#End Region
    End Class
End Namespace